package com.zxq.frame.msg;

import com.zxq.exchange.EFrame;
import com.zxq.frame.msg.device.*;
import com.zxq.tcp.handler.dispatch.TCPDispatchHandler;

public class TCPDispatchHandlerFactory {

    /**
     * register_tcp_modbus 注册协议
     */
    static SFRegistrationHandler SFRegistrationHandler = new SFRegistrationHandler();

    /**
     * modbus协议
     */
   static TCPModBusDispatchHandler tcpModbusDispatchHandler = new TCPModBusDispatchHandler();

    /**
     * dlt645协议
     */
    static DLT645TCPDispatchHandler dlt645TCPDispatchHandler = new DLT645TCPDispatchHandler();

    /**
     * jt808协议
     */
    static JT808DispatchHandler jt808DispatchHandler = new JT808DispatchHandler();


    /**
     * 方研充电桩协议
     */
    static IEC104DispatchHandler IEC104DispatchHandler = new IEC104DispatchHandler();



    /**
     * 根据tcp类型，生成对应的handler
     * @param eFrame tcp类型
     * @return
     */
    public static TCPDispatchHandler create(EFrame eFrame) {
        TCPDispatchHandler dispatchHandler = null;
        switch (eFrame) {
            case sf_register:
                dispatchHandler = SFRegistrationHandler;
                break;
            case iec_104:
                dispatchHandler = IEC104DispatchHandler;
                break;
            case modbus:
                dispatchHandler = tcpModbusDispatchHandler;
                break;
            case dlt645:
                dispatchHandler = dlt645TCPDispatchHandler;
                break;
            case jt808:
                dispatchHandler = jt808DispatchHandler;
                break;
        }
        return dispatchHandler;
    }


}
